package redis

import (
	"smart-flow/server/config"
	"strconv"

	"github.com/go-redis/redis/v8"
)

var RDB *redis.Client

func InitRedisPool(config config.RedisConfig) {
	doInitRedisPool(config.Ip, config.Port, config.Password, config.Db, config.PoolSize)
}

func doInitRedisPool(ip string, port int, password string, db int, poolSize int) {
	RDB = redis.NewClient(&redis.Options{
		Addr:     ip + ":" + strconv.Itoa(port),
		Password: password,
		DB:       db,
		PoolSize: poolSize,
	})
}
